package m.member.manage.model;

import m.common.model.FieldMeta;
import m.common.model.LinkTableMeta;
import m.common.model.TableMeta;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;
import m.system.cache.FlushCache;
import m.system.cache.FlushCacheList;
import manage.model.StatusModel;

import java.util.List;

@TableMeta(name="t_level_up_set",description="会员级别升级表")
public class LevelUpSet extends StatusModel implements FlushCache {
    @LinkTableMeta(name="before_level_oid",table= MemberLevel.class,description="之前级别")
    private MemberLevel beforeLevel;
    @LinkTableMeta(name="after_level_oid",table= MemberLevel.class,description="之后级别")
    private MemberLevel afterLevel;
    @FieldMeta(name = "use_money",type = FieldType.DOUBLE,description = "消费金额")
    private Double useMoney;
    @FieldMeta(name = "order_num",type = FieldType.INT,description = "订单数")
    private Integer orderNum;
    @FieldMeta(name="remark",type= FieldType.STRING,length=500,description="备注")
    private String remark;

    public MemberLevel getBeforeLevel() {
        return beforeLevel;
    }

    public void setBeforeLevel(MemberLevel beforeLevel) {
        this.beforeLevel = beforeLevel;
    }

    public MemberLevel getAfterLevel() {
        return afterLevel;
    }

    public void setAfterLevel(MemberLevel afterLevel) {
        this.afterLevel = afterLevel;
    }

    public Double getUseMoney() {
        return useMoney;
    }

    public void setUseMoney(Double useMoney) {
        this.useMoney = useMoney;
    }

    public Integer getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(Integer orderNum) {
        this.orderNum = orderNum;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Override
    public LevelUpSet getCacheModel(String key) throws Exception {
        return ModelQueryList.getModel(LevelUpSet.class,new String[]{"*","beforeLevel.*","afterLevel.*"},
            QueryCondition.and(
                QueryCondition.eq("beforeLevel.oid",key),
                QueryCondition.eq("status","0")
            )
        );
    }
}
